package com.example.fg;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public class FragmentB extends Fragment {

    private View mLayoutView;
    private Context mContext;
    private TextView mTvTestB;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.mContext=context;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mLayoutView = inflater.inflate(R.layout.fragment_b, container, false);

        initView();
        initData();
        setListener();

        return mLayoutView;
    }

    private void initView(){
        mTvTestB =mLayoutView.findViewById(R.id.tv_b);
    }

    private void initData(){
        Bundle bundle=getArguments();
        String value="";
        if(bundle!=null) {
             value = bundle.getString("B");
        }
        mTvTestB.setText("我是 B Fragment:  "+value);
    }

    private void setListener(){}

}